Strict

Import calb3d

Public

#If( TARGET <> "html5" And TARGET <> "flash" And TARGET <> "glfw"  )
  #Error "Cal3d is currently not available for target '${TARGET}'."
#End If

#If( TARGET = "html5" )
	Import "native/${TARGET}/base.${LANG}"
	Import "native/${TARGET}/math.${LANG}"
	Import "native/${TARGET}/bounding.${LANG}"
	Import "native/${TARGET}/corematerial.${LANG}"
	Import "native/${TARGET}/coresubmesh.${LANG}"
	Import "native/${TARGET}/coremesh.${LANG}"
	Import "native/${TARGET}/corebone.${LANG}"
	Import "native/${TARGET}/coreskeleton.${LANG}"
	Import "native/${TARGET}/coremodel.${LANG}"
	Import "native/${TARGET}/coresubmorphtarget.${LANG}"
	Import "native/${TARGET}/coremorphanimation.${LANG}"
	Import "native/${TARGET}/corekeyframe.${LANG}"
	Import "native/${TARGET}/coretrack.${LANG}"
	Import "native/${TARGET}/coreanimation.${LANG}"
	Import "native/${TARGET}/submesh.${LANG}"
	Import "native/${TARGET}/mesh.${LANG}"
	Import "native/${TARGET}/bone.${LANG}"
	Import "native/${TARGET}/skeleton.${LANG}"
	Import "native/${TARGET}/model.${LANG}"
	Import "native/${TARGET}/animation.${LANG}"
	Import "native/${TARGET}/mixer.${LANG}"
	Import "native/${TARGET}/morphtargetmixer.${LANG}"
	Import "native/${TARGET}/physique.${LANG}"
	Import "native/${TARGET}/springsystem.${LANG}"
	Import "native/${TARGET}/renderer.${LANG}"
	Import "native/${TARGET}/loader.${LANG}"
	Import "native/${TARGET}/datasource.${LANG}"
	Import "native/${TARGET}/error.${LANG}"
	'Import "native/${TARGET}/jsc3d.${LANG}"
#Elseif( TARGET = "flash" )	
	'Import "native/${TARGET}/base.${LANG}"
	Import "native/${TARGET}/datatypes/CalVector.${LANG}"
	Import "native/${TARGET}/datatypes/CalQuaternion.${LANG}"
	Import "native/${TARGET}/datatypes/CalMatrix.${LANG}"
	Import "native/${TARGET}/datatypes/Vertex.${LANG}"
	Import "native/${TARGET}/datatypes/Spring.${LANG}"
	Import "native/${TARGET}/datatypes/BlendVertex.${LANG}"
	Import "native/${TARGET}/datatypes/Influence.${LANG}"
	Import "native/${TARGET}/datatypes/TextureCoordinate.${LANG}"
	Import "native/${TARGET}/datatypes/PhysicalProperty.${LANG}"	
	Import "native/${TARGET}/datatypes/Face.${LANG}"
	Import "native/${TARGET}/datatypes/CalBoundingBox.${LANG}"
	Import "native/${TARGET}/core/CalCoreMaterial.${LANG}"
	Import "native/${TARGET}/core/CalCoreSubmesh.${LANG}"
	Import "native/${TARGET}/core/CalCoreMesh.${LANG}"
	Import "native/${TARGET}/core/CalCoreBone.${LANG}"
	Import "native/${TARGET}/core/CalCoreSkeleton.${LANG}"
	Import "native/${TARGET}/core/CalCoreModel.${LANG}"
	Import "native/${TARGET}/core/CalCoreSubMorphTarget.${LANG}"
	Import "native/${TARGET}/CalAnimation.${LANG}"
	Import "native/${TARGET}/core/animation/CalCoreMorphAnimation.${LANG}"
	Import "native/${TARGET}/core/animation/CalCoreKeyframe.${LANG}"
	Import "native/${TARGET}/core/CalCoreTrack.${LANG}"
	Import "native/${TARGET}/core/animation/CalCoreAnimation.${LANG}"
	Import "native/${TARGET}/core/animation/AnimationAction.${LANG}"
	Import "native/${TARGET}/core/animation/CalAnimationCycle.${LANG}"
	Import "native/${TARGET}/events/CalEvent.${LANG}"
	Import "native/${TARGET}/CalConstant.${LANG}"
	'Import "native/${TARGET}/Entry.${LANG}"
	'Import "native/${TARGET}/EntrySet.${LANG}"
	'Import "native/${TARGET}/KeySet.${LANG}"
	'Import "native/${TARGET}/ValueSet.${LANG}"
	'Import "native/${TARGET}/IObject.${LANG}"
	'Import "native/${TARGET}/IMapEntry.${LANG}"	
	'Import "native/${TARGET}/ObjectHash.${LANG}"
	'Import "native/${TARGET}/HashMap.${LANG}"
	'Import "native/${TARGET}/HashMapIterator.${LANG}"
	
	Import "native/${TARGET}/CalAbstractMixer.${LANG}"
	Import "native/${TARGET}/CalSubmesh.${LANG}"
	Import "native/${TARGET}/CalMesh.${LANG}"
	Import "native/${TARGET}/CalBone.${LANG}"
	Import "native/${TARGET}/CalSkeleton.${LANG}"
	Import "native/${TARGET}/CalModel.${LANG}"
	
	Import "native/${TARGET}/CalMixer.${LANG}"
	Import "native/${TARGET}/CalMorphTargetMixer.${LANG}"
	Import "native/${TARGET}/CalPhysique.${LANG}"
	Import "native/${TARGET}/physics/CalSpringSystem.${LANG}"
	Import "native/${TARGET}/CalRenderer.${LANG}"
	Import "native/${TARGET}/loaders/CalLoader.${LANG}"
	'Import "native/${TARGET}/datasource.${LANG}"
	'Import "native/${TARGET}/Error.${LANG}"
	
#Elseif( TARGET = "glfw" )
	Import "native/${TARGET}/vector.${LANG}"
	'Import "native/${TARGET}/math.${LANG}"
	'Import "native/${TARGET}/bounding.${LANG}"
	Import "native/${TARGET}/corematerial.${LANG}"
	Import "native/${TARGET}/coresubmesh.${LANG}"
	Import "native/${TARGET}/coremesh.${LANG}"
	Import "native/${TARGET}/corebone.${LANG}"
	Import "native/${TARGET}/coreskeleton.${LANG}"
	Import "native/${TARGET}/coremodel.${LANG}"
	Import "native/${TARGET}/coresubmorphtarget.${LANG}"
	Import "native/${TARGET}/coremorphanimation.${LANG}"
	Import "native/${TARGET}/corekeyframe.${LANG}"
	Import "native/${TARGET}/coretrack.${LANG}"
	Import "native/${TARGET}/coreanimation.${LANG}"
	Import "native/${TARGET}/submesh.${LANG}"
	Import "native/${TARGET}/mesh.${LANG}"
	Import "native/${TARGET}/bone.${LANG}"
	Import "native/${TARGET}/skeleton.${LANG}"
	Import "native/${TARGET}/model.${LANG}"
	Import "native/${TARGET}/animation.${LANG}"
	Import "native/${TARGET}/mixer.${LANG}"
	Import "native/${TARGET}/morphtargetmixer.${LANG}"
	Import "native/${TARGET}/physique.${LANG}"
	Import "native/${TARGET}/springsystem.${LANG}"
	Import "native/${TARGET}/renderer.${LANG}"
	Import "native/${TARGET}/loader.${LANG}"
	Import "native/${TARGET}/platform.${LANG}"
	Import "native/${TARGET}/error.${LANG}"
	

#End If

Public


Extern



#If( TARGET = "html5" )
	Class CalCoreSkeleton = "Cal3D.CalCoreSkeleton"
		Method calculateBoundingBoxes:Void(coreModel:CalCoreModel)
	End Class
	
	Class CalModel = "Cal3D.CalModel"
		Method getRenderer:CalRenderer()
		Method attachMesh:Bool(coreMeshId:Int)
		Method update:Void(delta:Float)
		Method getMixer:CalMixer()
	End Class
	
	Class CalCoreModel = "Cal3D.CalCoreModel"
		Method addCoreMesh:Int(coreMesh:CalCoreMesh)
		Method setCoreSkeleton:Void(coreSkeleton:CalCoreSkeleton)
		Method addCoreAnimation:Int(coreAnimation:CalCoreAnimation)
		Method makemodel:CalModel()
		Method getCoreSkeleton:CalCoreSkeleton()
		
	End Class
	
	Class CalCoreMesh = "Cal3D.CalCoreMesh"
		Method addCoreSubmesh:Int(coreSubmesh:CalCoreSubMesh)
		Method getCoreSubmesh:CalCoreSubMesh(coreSubmeshId:Int)
		Method getCoreSubmeshCount:Int()
		'Method getVectorCoreSubmesh
		Method addAsMorphTarget:Int(coreMesh:CalCoreMesh)
		Method scale:Void(factor:Float)
		Method setFilename:Void(filename:String)
		Method getFilename:String()
		Method setName:Void(name:String)
		Method getName:String()
	End Class
	
	Class CalCoreSubMesh = "Cal3D.CalCoreSubmesh"
		Method getCoreMaterialThreadId:Int()
		Method getFaceCount:Int()
		Method getLodCount:Int()
		Method getSpringCount:Int()
		'Method getVectorFace
		'Method getVectorPhysicalProperty
		'Method getVectorSpring
		'Method getVectorVectorTangentSpace
		'Method getVectorVectorTextureCoordinate
		'Method getVectorVertex
		Method getVertexCount:Int()
		Method isTangentsEnabled:Bool(mapId:Int)
		Method enableTangents:Bool(mapId:Int, enabled:Bool)
		Method reserve:Bool(vertexCount:Int, textureCoordinateCount:Int, faceCount:Int, springCount:Int)
		Method setCoreMaterialThreadId:Void(coreMaterialThreadId:Int)
		Method setFace:Bool(faceId:Int, face:CalCoreFace)
		Method setLodCount:Void(lodCount:Int)
		Method setPhysicalProperty:Bool(vertexId:Int, physicalProperty:CalCorePhysicalProperty)
		Method setSpring:Bool(springId:Int, spring:CalCoreSpring)
		Method setTangentSpace:Bool(vertexId:Int, textureCoordinateId:Float, tangent:Cal3DVector, crossFactor:Float)	
		Method setTextureCoordinate:Bool(vertexId:Int, textureCoordinateId:Int, textureCoordinate:CalTexCoord)
	End Class
	

	
	Class Cal3DVector = "Cal3D.CalVector"
		Method addLocal:Cal3DVector(v:Cal3DVector)
		Method subLocal:Cal3DVector(v:Cal3DVector)
		Method multScalarLocal:Cal3DVector(factor:Float)

	End Class
	
	Class CalTexCoord = "Cal3D.CalCoreSubmesh.TextureCoordinate"
	
	End Class
	
	Class CalCoreSpring = "Cal3D.CalCoreSubmesh.Spring"
	
	End Class
	
	Class CalCorePhysicalProperty = "Cal3D.CalCoreSubmesh.PhysicalProperty"
	
	End Class
	
	Class CalCoreFace = "Cal3D.CalCoreSubmesh.Face"
	
	End Class
	
	Class CalMixer = "Cal3D.CalMixer"
		Method clearCycle:Bool(id:Int, delay:Float)
		Method blendCycle:Bool(id:Int, weight:Float, delay:Float)
		Method executeAction:Bool(id:Int, delayIn:Float, delayOut:Float, weightTarget:Float, autoLock:Bool)
		
	End Class
	
	Class CalCoreAnimation = "Cal3D.CalCoreAnimation"
	
	End Class
	
	Class CalRenderer = "Cal3D.CalRenderer"
		Method beginRendering:Void()
		Method endRendering:Void()
		Method selectMeshSubmesh:Bool(meshId:Int, submeshId:int)
		Method getMeshCount:Int()
		Method getSubmeshCount:Int(meshId:Int)
		Method getFaceCount:Int()
		Method getVertexCount:Int()
		Method getVertices:Int(verts:Float[],stride:Int=3)
		Method getFaces:Int(faceBuffer:Int[])
		Method getNormals:Int(normalBuffer:Float[], stride:Int=3)
	End Class
	
	
	Function CalStringtoXML:Object(data:String) = "Cal3D.CalLoader.StringtoXml"
	Function LoadCalXMLSkeleton:CalCoreSkeleton(xmlskel:Object) = "Cal3D.CalLoader.parseXmlCoreSkeleton"
	Function LoadCalXMLMesh:CalCoreMesh(xmlmesh:Object) = "Cal3D.CalLoader.parseXmlCoreMesh"
	Function LoadCalXMLAnimation:CalCoreAnimation(xmlanim:Object,skel:CalCoreSkeleton) = "Cal3D.CalLoader.parseXmlCoreAnimation"

#Elseif( TARGET = "glfw" )	

	Class CalCoreSkeleton = "CalCoreSkeleton"
		Method calculateBoundingBoxes:Void(coreModel:CalCoreModel)
	End Class	




	
#Elseif( TARGET = "flash" )	

	Class CalCoreSkeleton = "CalCoreSkeleton"
		Method calculateBoundingBoxes:Void(coreModel:CalCoreModel)
	End Class

	Class CalModel = "CalModel"
		Method getRenderer:CalRenderer()
		Method attachMesh:Bool(coreMeshId:Int)
		Method update:Void(delta:Float)
		Method getMixer:CalMixer()
	End Class
	
	Class CalCoreModel = "CalCoreModel"
		Method addCoreMesh:Int(coreMesh:CalCoreMesh)
		Method setCoreSkeleton:Void(coreSkeleton:CalCoreSkeleton)
		Method addCoreAnimation:Int(coreAnimation:CalCoreAnimation)
		Method makemodel:CalModel()
		Method getCoreSkeleton:CalCoreSkeleton()
		
	End Class


	Class CalCoreMesh = "CalCoreMesh"
		Method addCoreSubmesh:Int(coreSubmesh:CalCoreSubMesh)
		Method getCoreSubmesh:CalCoreSubMesh(coreSubmeshId:Int)
		Method getCoreSubmeshCount:Int()
		'Method getVectorCoreSubmesh
		Method addAsMorphTarget:Int(coreMesh:CalCoreMesh)
		Method scale:Void(factor:Float)
		Method setFilename:Void(filename:String)
		Method getFilename:String()
		Method setName:Void(name:String)
		Method getName:String()
	End Class

	Class CalCoreSubMesh = "CalCoreSubmesh"
		Method getCoreMaterialThreadId:Int()
		Method getFaceCount:Int()
		Method getLodCount:Int()
		Method getSpringCount:Int()
		'Method getVectorFace
		'Method getVectorPhysicalProperty
		'Method getVectorSpring
		'Method getVectorVectorTangentSpace
		'Method getVectorVectorTextureCoordinate
		'Method getVectorVertex
		Method getVertexCount:Int()
		Method isTangentsEnabled:Bool(mapId:Int)
		Method enableTangents:Bool(mapId:Int, enabled:Bool)
		Method reserve:Bool(vertexCount:Int, textureCoordinateCount:Int, faceCount:Int, springCount:Int)
		Method setCoreMaterialThreadId:Void(coreMaterialThreadId:Int)
		Method setFace:Bool(faceId:Int, face:CalCoreFace)
		Method setLodCount:Void(lodCount:Int)
		Method setPhysicalProperty:Bool(vertexId:Int, physicalProperty:CalCorePhysicalProperty)
		Method setSpring:Bool(springId:Int, spring:CalCoreSpring)
		Method setTangentSpace:Bool(vertexId:Int, textureCoordinateId:Float, tangent:Cal3DVector, crossFactor:Float)	
		Method setTextureCoordinate:Bool(vertexId:Int, textureCoordinateId:Int, textureCoordinate:CalTexCoord)
	End Class

	Class Cal3DFace = "Face"
		Method Get:Int[]()
	End Class
	
	Class Cal3DVertex = "Vertex"
		Method getx:Float()
		Method gety:Float()
		Method getz:Float()		
	End Class
	
	Class Cal3DVector = "CalVector"
		Method addLocal:Cal3DVector(v:Cal3DVector)
		Method subLocal:Cal3DVector(v:Cal3DVector)
		Method multScalarLocal:Cal3DVector(factor:Float)
		Method getx:Float()
		Method gety:Float()
		Method getz:Float()		
	End Class
	
	Class CalTexCoord = "TextureCoordinate"
	
	End Class
	
	Class CalCoreSpring = "CalSpringSystem"
	
	End Class
	
	Class CalCorePhysicalProperty = "PhysicalProperty"
	
	End Class
	
	Class CalCoreFace = "Face"
	
	End Class



	Class CalMixer = "CalMixer"
		Method clearCycle:Bool(id:Int, delay:Float)
		Method blendCycle:Bool(id:Int, weight:Float, delay:Float)
		Method executeAction:Bool(id:Int, delayIn:Float, delayOut:Float, weightTarget:Float, autoLock:Bool)
		
	End Class
	
	Class CalCoreAnimation = "CalCoreAnimation"
	
	End Class
	
	Class CalRenderer = "CalRenderer"
		Method beginRendering:Bool()
		Method endRendering:Void()
		Method selectMeshSubmesh:Bool(meshId:Int, submeshId:int)
		Method getMeshCount:Int()
		Method getSubmeshCount:Int(meshId:Int)
		Method getFaceCount:Int()
		Method getVertexCount:Int()
		Method getVertices:Cal3DVertex[](stride:Int=3)
		Method getVerticesf:Int(verts:Float[],stride:Int=3)
		Method getFaces:Cal3DFace[]() 'This returns an array instead of accepting one.
		Method getNormals:Cal3DVector[](stride:Int=3) 'Same deal just make sure B3d class changes accordingly
	End Class

	Function LoadCalXMLSkeleton:CalCoreSkeleton(xmlskel:String) = "CalLoader.parseXmlCoreSkeleton"
	Function LoadCalXMLMesh:CalCoreMesh(xmlmesh:String) = "CalLoader.parseXmlCoreMesh"
	Function LoadCalXMLAnimation:CalCoreAnimation(xmlanim:String,skel:CalCoreSkeleton) = "CalLoader.parseXmlCoreAnimation"
	
#End If



